package vip.meeet.config;


import org.springframework.context.annotation.Configuration;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.transaction.annotation.EnableTransactionManagement;

@Configuration
@EnableJpaRepositories(basePackages = {"vip.mycollege.mysql.jpa.repository"})
@EnableTransactionManagement
public class SpringDataJPAConfig {

//    @Bean
//    public JpaVendorAdapter jpaVendorAdapter() {// 配置JPA厂商适配器
//        HibernateJpaVendorAdapter jpaVendorAdapter = new HibernateJpaVendorAdapter();
//        jpaVendorAdapter.setDatabase(Database.MYSQL);
//        // 是否打印sql语句
//        jpaVendorAdapter.setShowSql(true);
//        // 是否生成ddl语句
//        jpaVendorAdapter.setGenerateDdl(true);
//        // 设置hibernate
//        jpaVendorAdapter.setDatabasePlatform("org.hibernate.dialect.MySQL5Dialect");
//        return jpaVendorAdapter;
//    }
//
//    @Bean
//    public LocalContainerEntityManagerFactoryBean entityManagerFactory(DataSource dataSource, JpaVendorAdapter jpaVendorAdapter) {
//        LocalContainerEntityManagerFactoryBean localContainerEntityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean();
//        // 注入数据源
//        localContainerEntityManagerFactoryBean.setDataSource(dataSource);
//        // 注入jpa厂商适配器
//        localContainerEntityManagerFactoryBean.setJpaVendorAdapter(jpaVendorAdapter);
//        // 设置扫描基本包
//        localContainerEntityManagerFactoryBean.setPackagesToScan("vip.mycollege.mysql.jpa.entity");
//        return localContainerEntityManagerFactoryBean;
//    }
//
//    @Bean
//    public PlatformTransactionManager transactionManager(EntityManagerFactory emf) {// 配置jpa事务管理器
//        JpaTransactionManager transactionManager = new JpaTransactionManager();
//        // 配置实体管理器工厂
//        transactionManager.setEntityManagerFactory(emf);
//        return transactionManager;
//    }
}
